package com.happyclub.lbj.service.impl;

import com.happyclub.lbj.service.IGetHotActivityList;
import com.happyclub.lbjdao.FindHotActivityList;
import com.happyclub.lbjdao.SaveActivityUser;
import com.happyclub.lbjdao.SendActivity;
import com.happyclub.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 高欢
 * @description TODO
 * @date 2019/4/6
 */
@Service
public class IGetHotActivityListImpl implements IGetHotActivityList {

    @Autowired
    FindHotActivityList findHotActivityList;
    @Autowired
    SaveActivityUser saveActivityUser;
    @Autowired
    SendActivity sendActivity;
    @Override
    public JsonResult getHotActivityList() {
        JsonResult<Object> jsonResult = new JsonResult<>();
        List<Object[]> hot = findHotActivityList.getHot();
        if (hot.size()==0){
            jsonResult.setErrorCode("500");
            jsonResult.setMsg("亲!目前还没有热门活动哟...");
            return jsonResult;
        }
        for (Object[] object:hot){
            object[0] = sendActivity.findById(object[0].toString()).get();
        }
        jsonResult.setResult(hot);
        return jsonResult;
    }
}
